package com.glink.manage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.glink.manage.domain.AttendanceBean;
import com.glink.manage.vo.attendance.AttendanceDateDetailVO;
import com.glink.manage.vo.attendance.AttendancePageVO;
import com.glink.manage.vo.attendance.AttendanceProjectStatisticsVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface AttendanceMapper extends BaseMapper<AttendanceBean>{
    IPage<AttendancePageVO> selectAttendanceStatistics(Page<?> page,
                                                       @Param("searchStr") String searchStr,
                                                       @Param("unitObjId") String unitObjId,
                                                       @Param("statisticalMonth") String statisticalMonth,
                                                       @Param("workIdList") List<String> workIdList
    );

    IPage<AttendancePageVO> selectAttendanceStatisticsGeneralContractingUnit(Page<?> page,
                                                       @Param("searchStr") String searchStr,
                                                       @Param("unitObjId") String unitObjId,
                                                       @Param("statisticalMonth") String statisticalMonth,
                                                       @Param("workIdList") List<String> workIdList
    );

    /**
     * 查询打卡日期
     * @param card 证件
     * @param searchStr 查询字符串
     * @param statisticalMonth 时间
     * @return 打卡日期
     */
    List<AttendanceDateDetailVO> selectCheckinDateByCardAndSearchStrAndCheckinDateBetweenOrderByCheckinDateDesc(@Param("card") String card,
                                                                                                                @Param("personOrgId") String personOrgId,
                                                                                                                @Param("searchStr") String searchStr,
                                                                                                                @Param("unitObjId") String unitObjId,
                                                                                                                @Param("statisticalMonth") String statisticalMonth);

    /**
     * 根据时间统计出勤人数
     * @param startDate 开始时间
     * @param endDate 结束时间
     * @param workIdList 工程
     * @return 统计
     */
    List<AttendanceProjectStatisticsVO> statisticsAttendanceByCheckinDateBetweenAndWorkIdIn(@Param("startDate") LocalDate startDate,
                                                                                            @Param("endDate") LocalDate endDate,
                                                                                            @Param("workIdList") List<String> workIdList);
}
